<template>
  <el-dialog title="新增字典类型" :visible.sync="dialogVisible" width="50%" :append-to-body="true">
    <div style="margin: 15px 0;"></div>
    <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
        <el-checkbox v-for="city in cities" :label="city" :key="city" @change="selectList">{{city}}</el-checkbox>
    </el-checkbox-group>
  </el-dialog>
</template>
<script>
import TreeSelect from "@/components/basic-treeselect/treeselect";
import { baseUrl } from "@/config/env";
const urls = {
  save: baseUrl + "/dict/sys-dict-type/add",
  list: baseUrl + "/dict/sys-dict-type/page"
};
export default {
  data() {
    return {
        dialogVisible: false,
        data: [],
        defaultCheckedKeys: [],
        checkAll: false,
        checkedCities: ['任务名称', '任务ID'],
        cities: [],
        isIndeterminate: true,
        dataList : [],
    };
  },
  components: {
    TreeSelect
  },
  methods: {
    selectList(e){
     
    },
    show(data,list) {
      this.cities = list;
      this.dataList = data;
      this.dialogVisible = true;
    },
    handleCheckAllChange(val) {
        this.checkedCities = val ? this.cities : [];
        this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
        console.log(value)
        this.data = value
        this.send()
        let checkedCount = value.length;
        this.checkAll = checkedCount === this.cities.length;
        this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
    },
    send() {
      this.$emit('send',{data : this.data})
    }
  }
};
</script>